package com.andeveloper.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/demo")
public class DemoController {
	
	@Autowired
	private Author author;
	
	@Autowired
	private UserDao userDao;
	@RequestMapping("/hello")
	public String sayHello() {
		return "hello,"+author.getName()+","+author.getAge() + " years old!";
	}
	
	@RequestMapping(value="/findUser/{userName}", produces= {MediaType.APPLICATION_JSON_VALUE})
	public User findUser(@PathVariable("userName") String userName) {
		User user = userDao.findByUserName(userName);
		return user;
	}
}
